import { deletePost, insertOnePost, updateOnePost, lookPost } from '@/api/post'

const getDefaultState = () => {}

const state = getDefaultState()

const mutations = {}

const actions = {
  // 条件查询
  async lookPost({ state }, post) {
    return new Promise((resolve, reject) => {
      lookPost(post)
        .then((response) => {
          resolve(response)
        })
        .catch((error) => {
          reject(error)
        })
    })
  },
  // 添加一条岗位分类
  async insertOnePost({ commit, state }, post) {
    return new Promise((resolve, reject) => {
      insertOnePost(post)
        .then((response) => {
          resolve(response)
        })
        .catch((error) => {
          reject(error)
        })
    })
  },
  // 修改岗位分类
  async updateOnePost({ commit, state }, post) {
    return new Promise((resolve, reject) => {
      updateOnePost(post)
        .then((response) => {
          resolve(response)
        })
        .catch((error) => {
          reject(error)
        })
    })
  },
  // 批量删除岗位分类
  async deletePost({ commit, state }, ids) {
    return new Promise((resolve, reject) => {
      deletePost(ids)
        .then((response) => {
          resolve(response)
        })
        .catch((error) => {
          reject(error)
        })
    })
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
